unit Options;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls;

type
  TOptionsForm = class(TForm)
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    rbBeep: TRadioButton;
    rbSound: TRadioButton;
    GroupBox4: TGroupBox;
    ckAutoLoad: TCheckBox;
    ckAutoSave: TCheckBox;
    ckMove: TCheckBox;
    ckMusic: TCheckBox;
    Label1: TLabel;
    ed2: TEdit;
    spBrown2: TSpeedButton;
    ed1: TEdit;
    spBrown1: TSpeedButton;
    cmdOK: TButton;
    cmdCancel: TButton;
    Bevel1: TBevel;
    cmdHelp: TButton;
    xSkin: TRadioGroup;
    OpenDialog: TOpenDialog;
    procedure cmdOKClick(Sender: TObject);
    procedure cmdCancelClick(Sender: TObject);
    procedure cmdHelpClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure spBrown1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  OptionsForm: TOptionsForm;

implementation

uses Main;

{$R *.DFM}

procedure TOptionsForm.cmdOKClick(Sender: TObject);
begin
  { Update Settings }

  MainForm.Settings.Skin := xSkin.ItemIndex + 1;
  MainForm.SetWindowSize;

  MainForm.Settings.Illegal     := ckMove.Checked;
  MainForm.Settings.IllegalType := rbBeep.Checked;
  MainForm.Settings.IllegalFile := ed1.Text;

  MainForm.Settings.AutoSave := ckAutoSave.Checked;
  MainForm.Settings.AutoLoad := ckAutoLoad.Checked;

  //MainForm.Settings.Music     := ckMusic.Checked;
  //MainForm.Settings.MusicFile := ed2.Text;

  { Apply Settings }
  if MainForm.WindowState <> wsMaximized then MainForm.SetWindowSize;

  Close;
end;

procedure TOptionsForm.cmdCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TOptionsForm.cmdHelpClick(Sender: TObject);
begin
//
end;

procedure TOptionsForm.FormShow(Sender: TObject);
begin
  { Load Settings }
  xSkin.ItemIndex := MainForm.Settings.Skin - 1;

  ckMove.Checked := MainForm.Settings.Illegal;
  if MainForm.Settings.IllegalType then
    rbBeep.Checked := True
  else rbSound.Checked := True;
  ed1.Text := MainForm.Settings.IllegalFile;

  ckAutoSave.Checked := MainForm.Settings.AutoSave;
  ckAutoLoad.Checked := MainForm.Settings.AutoLoad;

  //ckMusic.Checked := MainForm.Settings.Music;
  //ed2.Text := MainForm.Settings.MusicFile;
end;

procedure TOptionsForm.spBrown1Click(Sender: TObject);
begin
  OpenDialog.InitialDir := ExtractFileDir(Application.ExeName);
  if OpenDialog.Execute then ed1.Text := OpenDialog.FileName; 
end;

end.
